package org.eliza.base.iox.path

import java.nio.file.LinkOption
import java.nio.file.Path
import java.nio.file.Paths
import java.nio.file.attribute.FileTime
import java.nio.file.attribute.UserPrincipal
import java.util.concurrent.TimeUnit
import kotlin.io.path.*

fun main() {
    val currentDir = Paths.get("").toAbsolutePath()
    println(currentDir)
              currentDir.isAbsolute

    val path = Path("./local.txt")
    val targetPath = Path("./target.txt")
    val toByteArray = "你好世界".toByteArray()
    val listOf = listOf("")

    println(path)
    println("writer                       ${path.writer()}")
    println("reader                       ${path.reader().toString()}")
    println("bufferedReader               ${path.bufferedReader()}")
    println("bufferedWriter               ${path.bufferedWriter()}")
    println("readBytes                    ${path.readBytes()}")
    println("writeBytes                   ${path.writeBytes(toByteArray)}")
    println("appendBytes                  ${path.appendBytes(toByteArray)}")
//    println("forEachLine                  ${path.forEachLine()}")
    println("inputStream                  ${path.inputStream()}")
    println("outputStream                 ${path.outputStream()}")
    println("readLines                    ${path.readLines()}")
    println("writeLines                   ${path.writeLines(listOf)}")
    println("appendLines                  ${path.appendLines(listOf)}")
    println("absolute                     ${path.absolute()}")
    println("absolutePathString           ${path.absolutePathString()}")
    println("copyTo                       ${path.copyTo(targetPath)}")
    println("exists                       ${path.exists()}")
    println("notExists                    ${path.notExists()}")
    println("isRegularFile                ${path.isRegularFile()}")
    println("isDirectory                  ${path.isDirectory()}")
    println("isSymbolicLink               ${path.isSymbolicLink()}")
    println("isExecutable                 ${path.isExecutable()}")
    println("isHidden                     ${path.isHidden()}")
    println("isReadable                   ${path.isReadable()}")
    println("isWritable                   ${path.isWritable()}")
    println("isSameFileAs                 ${path.isSameFileAs(targetPath)}")
//    println("forEachDirectoryEntry        ${path.forEachDirectoryEntry()}")
    println("fileSize                     ${path.fileSize()}")
    println("deleteExisting               ${path.deleteExisting()}")
    println("deleteIfExists               ${path.deleteIfExists()}")
    println("createDirectory              ${path.createDirectory()}")
    println("createDirectories            ${path.createDirectories()}")
    println("moveTo                       ${path.moveTo(targetPath)}")
    println("fileStore                    ${path.fileStore()}")
//    println("getAttribute                 ${path.getAttribute()}")
//    println("setAttribute                 ${path.setAttribute()}")
    println("readAttributes               ${path.readAttributes<java.nio.file.attribute.BasicFileAttributes>(LinkOption.NOFOLLOW_LINKS)}")
    println("getLastModifiedTime          ${path.getLastModifiedTime()}")
    println("setLastModifiedTime          ${path.setLastModifiedTime(FileTime.from(12L, TimeUnit.HOURS))}")
    println("getOwner                     ${path.getOwner()}")
//    println("setOwner                     ${path.setOwner()}")
    println("getPosixFilePermissions      ${path.getPosixFilePermissions()}")
    println("setPosixFilePermissions      ${path.setPosixFilePermissions(setOf())}")
//    println("createLinkPointingTo         ${path.createLinkPointingTo()}")
//    println("createSymbolicLinkPointingTo ${path.createSymbolicLinkPointingTo()}")
    println("readSymbolicLink             ${path.readSymbolicLink()}")
    println("createFile                   ${path.createFile()}")
}